<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class BaseModel extends Model
{
    public function getTableFields()
    {
        $fields = DB::select("select COLUMN_NAME from information_schema.COLUMNS where table_name= ?", [config('database.connections.mysql.prefix') . $this->table]);
        $return_data = [];
        array_map(function ($item) use (&$return_data) {
            $return_data[] = $item->COLUMN_NAME;
        }, $fields);

        return $return_data;
    }

    protected static function newModel()
    {
        return (new static);
    }
}
